<!--
 * @Autor: dingxiaolin
 * @Date: 2021-07-21 16:20:22
 * @LastEditors: dingxiaolin
 * @LastEditTime: 2021-07-23 15:03:33
-->
<template>
    <div class="page-header-index-wide">
        <a-card :bordered="false" :bodyStyle="{ padding: '16px 0', height: '100%' }" :style="{ height: '100%' }">
            <div class="account-settings-info-main">
                <div class="account-settings-info-left">
                    <a-menu
                        mode="inline"
                        :style="{ border: '0', width: 'auto' }"
                        :selectedKeys="selectedKeys"
                        type="inner"
                        @openChange="onOpenChange"
                    >
                        <a-menu-item key="/settings/base">
                            <router-link :to="{ name: 'baseSettings' }"> 基本设置 </router-link>
                        </a-menu-item>
                        <a-menu-item key="/settings/security">
                            <router-link :to="{ name: 'securitySettings' }"> 安全设置 </router-link>
                        </a-menu-item>
                        <a-menu-item key="/settings/custom">
                            <router-link :to="{ name: 'customSettings' }"> 个性化 </router-link>
                        </a-menu-item>
                        <a-menu-item key="/settings/notification">
                            <router-link :to="{ name: 'notificationSettings' }"> 新消息通知 </router-link>
                        </a-menu-item>
                    </a-menu>
                </div>
                <div class="account-settings-info-right">
                    <div class="account-settings-info-title">
                        <span>{{ $route.meta.title }}</span>
                    </div>
                    <router-view></router-view>
                </div>
            </div>
        </a-card>
    </div>
</template>

<script lang='ts'>
import { defineComponent, reactive, toRefs, ref, computed, watch, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useStore } from '@/store'
export default defineComponent({
    name: 'settings',
    components: {},
    props: {},
    emits: [],
    setup(props, ctx) {
        const routes = useRoute()
        const store = useStore()
        const state = reactive({
            openKeys: [],
            selectedKeys: [] as string[]
        })
        watch(
            () => routes.path,
            (v) => {
                updateMenu()
            },
            { immediate: true }
        )
        onMounted(() => {})
        function onOpenChange(openKeys) {
            state.openKeys = openKeys
        }
        function updateMenu() {
            routes.matched.concat()
            state.selectedKeys = [routes.path]
        }
        return {
            ...toRefs(state),
            onOpenChange,
            updateMenu
        }
    }
})
</script>

<style lang='scss' scoped>
.page-header-index-wide {
    height: 100%;
}
.account-settings-info-main {
    width: 100%;
    display: flex;
    height: 100%;
    overflow: auto;

    &.mobile {
        display: block;

        .account-settings-info-left {
            border-right: unset;
            border-bottom: 1px solid #e8e8e8;
            width: 100%;
            height: 50px;
            overflow-x: auto;
            overflow-y: scroll;
        }
        .account-settings-info-right {
            padding: 20px 40px;
        }
    }

    .account-settings-info-left {
        border-right: 1px solid #e8e8e8;
        width: 224px;
    }

    .account-settings-info-right {
        flex: 1 1;
        padding: 8px 40px;

        .account-settings-info-title {
            color: rgba(0, 0, 0, 0.85);
            font-size: 20px;
            font-weight: 500;
            line-height: 28px;
            margin-bottom: 12px;
        }
        .account-settings-info-view {
            padding-top: 12px;
        }
    }
}
</style>
